package com.pgybook.db.entity.mapper;

import org.springframework.stereotype.Repository;
import com.pgybook.db.entity.domain.CustomerBookShelf;
import com.pgybook.db.entity.domain.CustomerBookShelfEx;

import java.util.List;

import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.ResultMap;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectKey;
import org.apache.ibatis.annotations.Update;

@Repository
public interface CustomerBookShelfMapper {
    int countByExample(CustomerBookShelfEx example);

    int deleteByExample(CustomerBookShelfEx example);

    @Delete({
            "delete from customerbookshelf",
            "where CUSTSHELFID = #{custshelfid,jdbcType=BIGINT}"
    })
    int deleteByPrimaryKey(Long custshelfid);

    @Insert({
            "insert into customerbookshelf (CUSTID, INSTANCEID, ",
            "BOOKID, LIBID, ORDERID, ",
            "CRTTIMR, STARTTIME, ",
            "ENDTIME)",
            "values (#{custid,jdbcType=BIGINT}, #{instanceid,jdbcType=BIGINT}, ",
            "#{bookid,jdbcType=BIGINT}, #{libid,jdbcType=INTEGER}, #{orderid,jdbcType=BIGINT}, ",
            "#{crttimr,jdbcType=TIMESTAMP}, #{starttime,jdbcType=TIMESTAMP}, ",
            "#{endtime,jdbcType=TIMESTAMP})"
    })
    @SelectKey(statement = "SELECT LAST_INSERT_ID()", keyProperty = "custshelfid", before = false, resultType = Long.class)
    int insert(CustomerBookShelf record);

    int insertSelective(CustomerBookShelf record);

    List<CustomerBookShelf> selectByExample(CustomerBookShelfEx example);

    @Select({
            "select",
            "CUSTSHELFID, CUSTID, INSTANCEID, BOOKID, LIBID, ORDERID, CRTTIMR, STARTTIME, ",
            "ENDTIME",
            "from customerbookshelf",
            "where CUSTSHELFID = #{custshelfid,jdbcType=BIGINT}"
    })
    @ResultMap("BaseResultMap")
    CustomerBookShelf selectByPrimaryKey(Long custshelfid);

    int updateByExampleSelective(@Param("record") CustomerBookShelf record, @Param("example") CustomerBookShelfEx example);

    int updateByExample(@Param("record") CustomerBookShelf record, @Param("example") CustomerBookShelfEx example);

    int updateByPrimaryKeySelective(CustomerBookShelf record);

    @Update({
            "update customerbookshelf",
            "set CUSTID = #{custid,jdbcType=BIGINT},",
            "INSTANCEID = #{instanceid,jdbcType=BIGINT},",
            "BOOKID = #{bookid,jdbcType=BIGINT},",
            "LIBID = #{libid,jdbcType=INTEGER},",
            "ORDERID = #{orderid,jdbcType=BIGINT},",
            "CRTTIMR = #{crttimr,jdbcType=TIMESTAMP},",
            "STARTTIME = #{starttime,jdbcType=TIMESTAMP},",
            "ENDTIME = #{endtime,jdbcType=TIMESTAMP}",
            "where CUSTSHELFID = #{custshelfid,jdbcType=BIGINT}"
    })
    int updateByPrimaryKey(CustomerBookShelf record);
}
